package com.bitdf.txing.users.service.impl;

import com.bitdf.txing.common.utils.PageUtils;
import com.bitdf.txing.common.utils.Query;
import com.bitdf.txing.users.dao.TeamInfoDao;
import com.bitdf.txing.users.entity.TeamInfoEntity;
import com.bitdf.txing.users.service.TeamInfoService;
import com.bitdf.txing.users.vo.TeamQueryVo;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

@Service("teamInfoService")
public class TeamInfoServiceImpl extends ServiceImpl<TeamInfoDao, TeamInfoEntity> implements TeamInfoService {

    /**
     * 分页查询
     * @param queryVo
     * @return
     */
    @Override
    public PageUtils queryPage(TeamQueryVo queryVo) {

        QueryWrapper<TeamInfoEntity> wrapper = new QueryWrapper<>();
        wrapper.lambda().like(queryVo.getTeamName() != null, TeamInfoEntity::getTeamName, "%" + queryVo.getTeamName() + "%")
                        .eq(queryVo.getLeaderId() != null, TeamInfoEntity::getLeaderId, queryVo.getLeaderId());
        IPage<TeamInfoEntity> page = this.page(
                new Query<TeamInfoEntity>().getPage(queryVo),
                wrapper
        );
        return new PageUtils(page);
    }

}